package com.oj.auth.proxy;

import com.oj.api.auth.AuthAPI;
import com.oj.api.auth.domain.AccountInfo;
import com.oj.api.auth.domain.ForgetInfo;
import com.oj.api.auth.domain.HomeResourceInfo;
import com.oj.api.auth.domain.RoleInfo;
import com.oj.api.auth.service.IAccountService;
import com.oj.common.IProxyLayer;
import com.oj.common.exception.BreezeeException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Bing
 * @since on 2018/5/4
 */
@RestController
@RequestMapping("/" + AuthAPI.BEAN_ACCOUNT_SERVICE)
public class AccountServiceProxy implements IAccountService, IProxyLayer {

    @Resource(name = AuthAPI.BEAN_ACCOUNT_SERVICE)
    private IAccountService accountService;

    @Override
    public AccountInfo checkPassword(@RequestBody AccountInfo accountInfo) throws BreezeeException {
        return accountService.checkPassword(accountInfo);
    }

    @Override
    public AccountInfo saveAccountInfo(@RequestBody AccountInfo accountInfo) {
        return accountService.saveAccountInfo(accountInfo);
    }

    @Override
    public RoleInfo createRole(@RequestBody RoleInfo roleInfo){
        return accountService.createRole(roleInfo);
    }

    @Override
    public ForgetInfo forgetPw(@RequestBody AccountInfo accountInfo) {
        return accountService.forgetPw(accountInfo);
    }

    @Override
    public ForgetInfo findForgetInfoById(@PathVariable("id") String id) {
        return accountService.findForgetInfoById(id);
    }

    @Override
    public AccountInfo resetPassword(@RequestBody AccountInfo accountInfo) {
        return accountService.resetPassword(accountInfo);
    }

    @Override
    public AccountInfo examLogin(@RequestBody AccountInfo accountInfo) {
        return accountService.examLogin(accountInfo);
    }

    @Override
    public AccountInfo findAccountInfoById(@PathVariable("id") String id) {
        return accountService.findAccountInfoById(id);
    }

    @Override
    public List<AccountInfo> getAccountList(@RequestBody AccountInfo accountInfo) {
        return accountService.getAccountList(accountInfo);
    }

    @Override
    public List<RoleInfo> getRoles(@RequestBody RoleInfo roleInfo) {
        return accountService.getRoles(roleInfo);
    }

    @Override
    public AccountInfo bindStudentCode(@RequestBody AccountInfo accountInfo) {
        return accountService.bindStudentCode(accountInfo);
    }

    @Override
    public HomeResourceInfo saveHomeResource(@RequestBody HomeResourceInfo homeResourceInfo) {
        return accountService.saveHomeResource(homeResourceInfo);
    }

    @Override
    public List<HomeResourceInfo> getHomeResource(@RequestBody HomeResourceInfo homeResourceInfo) {
        return accountService.getHomeResource(homeResourceInfo);
    }
}
